<template>
  <div class='u-sys_balanceOfProject_add'>
    <el-dialog
      title="收支项目详情"
      :visible.sync="dialogVisible"
      :before-close="close">
      <select-list aType='6' @update='getClassid' />
      <div class='u-sys_balanceOfProject_add-btn'>
        <el-button type='primary' @click='confirm'>确定</el-button>
        <el-button type='primary' @click='close'>关闭窗口</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import selectList from '@/components/selectDialog/selectAttrList'

export default {
  name: 'u-sys_balanceOfProject_add',

  components: {
    selectList
  },

  data() {
    return {
      classId: '',
      dialogVisible: false
    }
  },

  props: ['id'],

  methods: {
    $show() {
      this.dialogVisible = true
    },

    getClassid(a, b, c) {
      this.classId = c || b || ''
    },

    close() {
      this.dialogVisible = false
    },

    async confirm() {
      // if (!this.classId) {
      //   return this.__notify('警告', '请选择属性分类', 'warning')
      // }
      const { code } = await this.$api.inventSetCostClass({
        aFirmId: this.aFirmId,
        aClassId: this.classId,
        aCostId: this.id
      })
      if (code === 0) {
        this.__notify('提示', '添加成功')
        this.$emit('update')
        this.dialogVisible = false
      }
    }
  }
}
</script>

<style lang='less'>
.u-sys_balanceOfProject_add {
  &-btn {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  .on {
    font-weight: bold;
  }
}
</style>